package br.com.covosys.jsf.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import org.springframework.util.StringUtils;

public class IntegerConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String value) {
		return StringUtils.hasText(value) ? Integer.valueOf(value.trim()) : null;
	}

	@Override
	public String getAsString(FacesContext arg0, UIComponent arg1, Object object) {
		return object == null ? null : object.toString();
	}
}